﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using IT_Tracker.ENTIDADES;
using IT_Tracker.DADOS;

namespace IT_Tracker
{
    public partial class Form_Log : Form
    {

        Usuario usuario = new Usuario();
        PersistenciaBDUsuario bdusuario = new PersistenciaBDUsuario();
        public Usuario sessionuser = new Usuario(); 

        public Form_Log()
        {
            InitializeComponent();
        }

        private void bt_login_Click(object sender, EventArgs e)
        {

            if (tb_Pass.Text == string.Empty || tb_User.Text == string.Empty)
            {
                MessageBox.Show("Favor Preencher Usuário e Senha", "Login", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            usuario.Login = Convert.ToInt32(tb_User.Text);
            usuario.Senha = tb_Pass.Text;

            if (bdusuario.CheckLogin(usuario))
            {
                sessionuser = bdusuario.GetUsuario(Convert.ToInt32(tb_User.Text));
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("Usuário ou Senha Invalidos", "Login", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

        }
        // Valida Somente Números no TB de Login
        private void tb_User_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsDigit(e.KeyChar) && e.KeyChar != (char)8)
            {
                e.Handled = true;
            }
        }



        /*Arredonda as bordas do Form
        protected void resizeForm()
        {
            System.Drawing.Drawing2D.GraphicsPath graphicpath = new System.Drawing.Drawing2D.GraphicsPath();

            graphicpath.StartFigure();

            graphicpath.AddArc(0, 0, 25, 25, 180, 90);

            graphicpath.AddLine(25, 0, this.Width - 25, 0);

            graphicpath.AddArc(this.Width - 25, 0, 25, 25, 270, 90);

            graphicpath.AddLine(this.Width, 25, this.Width, this.Height - 25);

            graphicpath.AddArc(this.Width - 25, this.Height - 25, 25, 25, 0, 90);

            graphicpath.AddLine(this.Width - 25, this.Height, 25, this.Height);

            graphicpath.AddArc(0, this.Height - 25, 25, 25, 90, 90);

            graphicpath.CloseFigure();

            this.Region = new Region(graphicpath);

        }
         */

    }
}
